#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>
 
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
 
const int p = 131, N = 2e6 + 10, mod = 1000000007;
 
int n;
char str[N];
ULL strHash[N], rstrHash[N];
ULL P[N];
 
ULL get(int l1, int r1, int l2, int r2){
   
    ULL k1 = (strHash[r1] - strHash[l1 - 1] * P[r1 - l1 + 1] % mod + mod) % mod;

    ULL k2 = (strHash[r2] - strHash[l2 - 1] * P[r2 - l2 + 1] % mod + mod) % mod;

    k1 = k1 * P[r2 - l2 + 1] % mod;
    ULL res = (k1 + k2) % mod;
 

    return res;
}
 
ULL rget(int l, int r){
    ULL k = (rstrHash[l] - rstrHash[r + 1] * P[r + 1 - l] % mod + mod) % mod ;
    return k;
}
 
int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
 
 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    cin >> n >> str + 1;
    P[0] = 1;
    for(int i = 1; i <= n * 2; i ++){
        P[i] = P[i - 1] * p % mod;
    }
 
 
    for(int i = 1; i <= n * 2; i ++){
        strHash[i] = (strHash[i - 1] * p % mod + (str[i] - 'a')) % mod;
    }
 
    for(int i = n * 2; i >= 1; i --){
        rstrHash[i] = (rstrHash[i + 1] * p % mod + (str[i] - 'a')) % mod;
    }
    // cout << int('a') << " " << int('g') << " " << int('c') << '\n';
    // cout << (get(1, 3, 7, 6) == rget(4, 6));
    // exit(0);
    for(int i = 1; i + n - 1 <= n * 2; i ++){
        int l = i, r = i + n - 1;
        ULL k1 = get(1, l - 1, r + 1, n * 2);
 
        // cout << "--------------------------" << '\n';
        ULL k2 = rget(l, r);
        // cout << get(1, 0, 4, 6) << '\n';
 
        // cout << "k1: " << k1 << " k2: " << k2 << '\n';
        if(k1 == k2){
            
            for(int p = 1; p <= i - 1; p ++) cout << str[p];
            for(int p = i + n; p <= n * 2; p ++) cout << str[p];
            cout << '\n';
            cout << i - 1 << '\n';
            exit(0);
        }
 
 
 
 
    }
    
            cout << -1 << '\n';
 
 
    return 0;
}